//
//  StatusCellPictureViewCell.m
//  OCMicroBlog
//
//  Created by 002 on 15/11/7.
//  Copyright © 2015年 002. All rights reserved.
//

#import "StatusCellPictureViewCell.h"
#import "UIImageView+WebCache.h"
#import "masonry.h"

@interface StatusCellPictureViewCell ()

@property(nonatomic,strong) UIImageView *iconView;

@end

@implementation StatusCellPictureViewCell



- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    
    [self setupUI];

    return self;
}


/**
 *  设置UI
 */
- (void)setupUI {
    
    // 1. 添加控件
    [self.contentView addSubview:self.iconView];
    
    // 2. 布局
    [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView.mas_top);
        make.left.equalTo(self.contentView.mas_left);
        make.bottom.equalTo(self.contentView.mas_bottom);
        make.right.equalTo(self.contentView.mas_right);
    }];
}

// 设置配图
- (void)setImageURL:(NSURL *)imageURL {
    
    if (imageURL) {
        [self.iconView sd_setImageWithURL:imageURL placeholderImage:nil options:SDWebImageRetryFailed | SDWebImageLowPriority];
    }
}

#pragma mark - 懒加载
- (UIImageView *)iconView {
    if (!_iconView) {
        _iconView = [[UIImageView alloc] init];
        
        // 设置图片填充模式
        _iconView.contentMode = UIViewContentModeScaleAspectFill;
        _iconView.clipsToBounds = true;
    }
    return _iconView;
}
@end
